package com.tianyadu.security.core.validate.code;

import lombok.Data;
import java.time.LocalDateTime;

/**
 * @FileName: SmsCode
 * @Description: 短信验证码生成
 * @author: xueyj
 * @create: 2018-12-13 11:13
 */
@Data
public class ValidateCode {

    /** 验证码 */
    private String code;

    /** 过期时间 */
    private LocalDateTime expireTime;

    public ValidateCode(String code, int expireIn){
        this.code = code;
        this.expireTime = LocalDateTime.now().plusSeconds(expireIn);
    }

    public ValidateCode(String code, LocalDateTime expireTime){
        this.code = code;
        this.expireTime = expireTime;
    }

    public boolean isExpried() {
        return LocalDateTime.now().isAfter(expireTime);
    }
}